﻿@{
    Layout = null;
}

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>用户注册</title>
    <link href="~/Content/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Content/signin.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-3.1.0.min.js"></script>
</head>

<body>
    <div class="container">
        <h2 class="form-signin-heading">用户注册</h2>
        <div class="form-group">
            <label for="name">用户名</label>
            <input id="name" class="form-control" placeholder="" name="name" required autofocus>
        </div>
        <div class="form-group">
            <label for="pwd">设置密码</label>
            <input id="pwd" type="password" class="form-control" placeholder="" name="pwd" required autofocus>
        </div>
        <div class="form-group">
            <label for="pwdCheck">验证密码</label>
            <input id="pwdCheck" type="password" class="form-control" placeholder="" name="pwdCheck" required autofocus>
        </div>
        <div class="form-group">
            <label for="phone">输入手机号码</label>
            <input id="phone" class="form-control" placeholder="" name="phone" required autofocus>
        </div>
        <div class="form-group">
            <label for="code">验证码</label>
            <input id="code" class="form-control" placeholder="" name="code" required autofocus>
            <button id="getCode" type="button" class="btn btn-default">获取短信验证码</button>
        </div>
        <div id="msgNo" class="alert alert-danger" role="alert"></div>
        <div id="msgYes" class="alert alert-success" role="alert"></div>
        <button id="register" class="btn btn-lg btn-primary btn-block" type="button">注 册</button>
    </div>
    <script type="text/javascript">
        $(function () {
            var msgNo = $("#msgNo");
            msgNo.hide();
            var msgYes = $("#msgYes");
            msgYes.hide();
            $("#getCode").click(function () {
                msgNo.hide();
                msgYes.hide();

                var phone=$("#phone").val();
                if(phone!=null && phone.length>0)
                {
                    $.ajax({
                        url:'@Url.Action("GetSecurityCode", "Mobile")',
                        type: 'post',
                        data: {phone:phone},
                        success: function (data) {
                            if(data.Code==1)
                            {
                                $("#code").val(data.Data);
                            }
                        }
                    });
                }
                else
                {
                    msgNo.html("请输入手机号码！");
                    msgNo.show();
                }
            });

            $("#register").click(function () {
                msgNo.hide();
                msgYes.hide();

                var name = $("#name").val();
                var pwd = $("#pwd").val();
                var phone = $("#phone").val();
                var code = $("#code").val();

                $.ajax({
                    url: '@Url.Action("Register", "Mobile")',
                    type: 'post',
                    data: { name:name,pwd:pwd,phone: phone,code:code },
                    success: function (data) {
                        if (data.Code == 1) {
                            @*window.location.href = '@Url.Action("Index", "Mobile")';*@
                            msgYes.html("注册成功！");
                            msgYes.show();
                        }
                        else
                        {
                            msgNo.html(data.Msg);
                            msgNo.show();
                        }
                    }
                });

            });
        }); 
    </script>
</body>
</html>

